package main

import (
	"frontdesk/handler"
	frontdesk "frontdesk/proto/frontdesk"
	"github.com/micro/go-micro"
	"github.com/micro/go-micro/registry"
	"github.com/micro/go-plugins/registry/consul"
	"log"
	"time"
)

func main() {
	// 注册consul
	reg := consul.NewRegistry(func(op *registry.Options) {
		op.Addrs = []string{
			"127.0.0.1:8500",
		}
	})

	// New Service
	service := micro.NewService(
		micro.Name("go.micro.api.frontdesk"),
		micro.Registry(reg),
		micro.RegisterTTL(time.Second*30),
		micro.RegisterInterval(time.Second*10),
	)

	// Initialise service
	service.Init()

	// Register Handler
	_ = frontdesk.RegisterFrontdeskHandler(service.Server(), handler.Handler(service.Client()))

	if err := service.Run(); err != nil {
		log.Fatal(err)
	}

}
